package com.lepu.app.fun.index.bean;

import java.io.Serializable;
import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;
import com.lepu.pasm.R;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

@SuppressWarnings("serial")
public class BeanIndexBook implements Serializable{
   public String title;
   public String author;
   public String content;
   public int imageUrl;
   public int index;
   
   public static ArrayList<BeanIndexBook> parseJsonData(String dataString) {
		String result = "";
		try {
			JSONObject jsonObject = new JSONObject(dataString);
			JSONObject obj1 = (JSONObject) jsonObject.get("Result");
			JSONObject obj2 = obj1.getJSONObject("DetailInfo");
			
			result = obj2.toString();
		} catch (JSONException e) {
			e.printStackTrace();
		}

		Gson gson = new Gson();
		ArrayList<BeanIndexBook> item = gson.fromJson(result,new TypeToken<BeanIndexBook>() {}.getType());
		return item;
	}
   
   public static ArrayList<BeanIndexBook> getTestData(){
	   ArrayList<BeanIndexBook> arrayList = new ArrayList<BeanIndexBook>();
	   
	   BeanIndexBook bean1 = new BeanIndexBook();
	   bean1.title = "教你平安度过“支架人生”";
	   bean1.author = "胡大一";
	   bean1.content = "经皮冠状动脉介入治疗(PCI)是目前治疗冠心病的重要手段。患者通过植入心脏冠脉支架解决病痛、延长生命、提高生活质量。然而，“支架植入”并非一劳永逸，只是治疗的开始。术后还需进行长期、系统、专业的身心等各方面健康调理，同时对高血压、高血糖以及包括吸烟在内的不良生活方式等冠心病危险因素认真防控，才能达到完全的康复。康复方法的正确与否很大程度上决定预后的效果。";
	   bean1.imageUrl = R.drawable.index_book_icon1;
	   bean1.index = 1;
	   
	   BeanIndexBook bean2 = new BeanIndexBook();
	   bean2.title = "心血管健康管理手册";
	   bean2.author = "同心管家";
	   bean2.content = "";
	   bean2.imageUrl = R.drawable.index_book_icon2;
	   bean2.index = 2;
	   
	   arrayList.add(bean1);
	   arrayList.add(bean2);
	   
	   return arrayList;
   }
   
}
